<template>
    <div class="addPermissionList">
        <el-dialog
            center
            :before-close="handClose"
            width="30%"
            title="提交采购订单"
            :visible.sync="off"
            append-to-body>
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" size="mini" class="demo-ruleForm">
                <el-form-item label="收货地址" prop="permissionName">
                    <el-input v-model.trim="ruleForm.address"></el-input>
                </el-form-item>
                <el-form-item label="付款方式" prop="payType">
                    <el-select v-model="ruleForm.payType">
                        <el-option :label="item.label" :value="item.value" v-for="(item, index) in payType" :key="index"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="区域选择">
                   <el-cascader
                        v-model="ruleForm.area"
                        :options="area"
                        @change="handleChange">
                   </el-cascader>
                </el-form-item>
                <el-form-item label="商品总金额" prop="money">
                    <el-input disabled v-model.trim="ruleForm.money"></el-input>
                </el-form-item>
                <el-form-item label="订总金额" prop="money">
                    <el-input disabled v-model.trim="ruleForm.money"></el-input>
                </el-form-item>
                <el-form-item label="实际总金额" prop="money">
                    <el-input disabled v-model.trim="ruleForm.money"></el-input>
                </el-form-item>
                <el-form-item label="发票" prop="isInvoice">
                   <el-select v-model="ruleForm.isInvoice">
                        <el-option :label="item.label" :value="item.value" v-for="(item, index) in invoice" :key="index"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="订单备注" prop="orderRemarks">
                    <el-input v-model.trim="ruleForm.orderRemarks"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submit">提交</el-button>
            </div>
        </el-dialog>
    </div>
   
</template>

<script>
    import { areaData } from "@/api/store/shopPurchase.js"
    export default {
        name: "submitOrder",
        props: {
            off: {
                type: Boolean
            },
            orderTotalMoney: {
                type: Number
            }
        },
        watch: {
            off(val){
                if(val){
                    this.ruleForm.money = this.orderTotalMoney;
                }
            }
        },
        data(){
            return {
                rules: {
                },
                payType: [
                    {label: "货到付款", value: 1},
                ],
                invoice: [
                    {label: "需要", value: 1},
                    {label: "不需要", value: 0},
                ],
                area: [],
                ruleForm: {
                    address: "",
                    money: "",
                    isInvoice: "",
                    orderRemarks: "",
                    payType: "",
                    area: ""
                }
            }
        },
        methods: {
            handleChange(){},
            handClose(){
                this.$emit("update:off", false);
            },
            submit(){
                this.$refs.ruleForm.validate((valid) => {
                    if(!valid){
                        return;
                    }else{
                        // var obj = {
                        //     permissionName: this.ruleForm.permissionName,
                        //     url: this.ruleForm.url
                        // }
                        addPerssion({
                            permissionName: this.ruleForm.permissionName,
                            url: this.ruleForm.url
                        }).then(
                            res => {
                                console.log("res新增权限", res);
                                this.$message({
                                    type: "success",
                                    message: "新增权限成功"
                                });
                                this.$emit("update:off", false);
                                this.$parent.getList();
                                this.ruleForm.resetFields();
                            },
                            err => {}
                        );
                    }
                });
            }
        }
    }
</script>

<style scoped lang="less">

</style>